package com.app.business.web.uni;

import com.app.business.en.HouseStatus;
import com.app.business.model.*;
import com.app.business.service.ContractService;
import com.app.business.service.uni.*;
import com.app.business.utils.BigUtils;
import com.app.business.utils.ChooseLimitUtils;
import com.app.system.permission.en.Status;
import com.app.system.permission.model.DataDict;
import com.app.system.permission.service.DataDictService;
import com.app.system.utils.CollectionUtils;
import com.app.system.utils.ParamUtils;
import com.app.system.utils.dataType.BigDecimalUtils;
import com.app.system.utils.dataType.StringUtils;
import com.app.system.utils.exception.Precondition;
import com.app.system.utils.exception.Response;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/app/house/*")
public class AppHouseController {
    @Autowired
    private AppHouseService appHouseService;
    @Autowired
    private DataDictService dataDictService;
    @Autowired
    private AppCarLotService appCarLotService;
    @Autowired
    private AppContractService appContractService;
    @Autowired
    private ContractService contractService;
    @Autowired
    private AppYxHouseService appYxHouseService;
    @Autowired
    private AppYxCarLotService appYxCarLotService;
    @Autowired
    private AppBxHouseService appBxHouseService;

    /**
     * 处理车位列表分页问题
     * @param request
     * @return
     */
    @RequestMapping("getCar")
    public Response getCar(HttpServletRequest request){
        String carNum = ParamUtils.getString(request, "carNum", "");
        Integer start = ParamUtils.getInteger(request, "start", 0);//开始数
        Integer pageSize = ParamUtils.getInteger(request, "pageSize", 0);//查询条数
        Map phoneInfoMap = dataDictService.getMapByParentNameForName_Value("手机端公示信息配置");
        String azProjectIdStr = phoneInfoMap.get("安置项目ID").toString();//安置项目id list
        //可选车位信息
        List<Map> resultCarList = Lists.newArrayList();
        start = start == null ? 0 : start;
        //车位列表
        List<CarLot> carLotList = this.appCarLotService.getCarLotListByZsProjectId(azProjectIdStr,carNum,start,pageSize);
        Integer pageNum = this.appCarLotService.getCarLotListByZsProjectIdSizw(azProjectIdStr,carNum);//条数
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");
        Map<String, DataDict> houseStatusMapItem = this.dataDictService.getMapByParentNameForValue("房源状态");

        if (CollectionUtils.isNotEmpty(carLotList)){
            Map<String, Object> mapItem = null;
            Integer houseStatus = null;
            for (CarLot carLot : carLotList) {
                mapItem = null;
                houseStatus = null;
                mapItem = Maps.newHashMap();
                mapItem.put("id", carLot.getId());
                mapItem.put("projectName", carLot.getAzProject().getProjectName());
                mapItem.put("buildNum", carLot.getBuildNum());
                mapItem.put("houseNum", carLot.getHouseNumStr());
                mapItem.put("floor", carLot.getFloor());
                mapItem.put("buildArea", carLot.getBuildArea());
                mapItem.put("carLotTypeStr", carLotTypeMap.get(carLot.getCarLotType().toString()).getName());
                mapItem.put("houseStatus", carLot.getHouseStatus());
                //如果是预留的，则显示为已选状态
                houseStatus = carLot.getHouseStatus().equals(HouseStatus.YULIU.getIndex()) ? HouseStatus.YIXUAN.getIndex() : carLot.getHouseStatus();
                mapItem.put("houseStatusStr", houseStatusMapItem.get(houseStatus.toString()).getName());
                resultCarList.add(mapItem);
            }
        }
        Map resultMap = Maps.newHashMap();
        resultMap.put("resultCarList",resultCarList);
        resultMap.put("pageNum",pageNum);
        return Response.success(resultMap);
    }

    /**
     * 测算协议列表
     * @param request
     * @return
     */
    @RequestMapping("getContractList")
    public Response getContractList(HttpServletRequest request){
        String likeStr = ParamUtils.getString(request, "likeStr", "");
        Integer start = ParamUtils.getInteger(request, "start", 0);//开始数
        Integer pageSize = ParamUtils.getInteger(request, "pageSize", 0);//查询条数
        Map phoneInfoMap = dataDictService.getMapByParentNameForName_Value("手机端公示信息配置");
        String zsProjectIdStr = phoneInfoMap.get("征收项目ID").toString();//安置项目id list
        //预选协议信息
        List<Map> resultContractList = Lists.newArrayList();
        start = start == null ? 0 : start;
        //协议列表
        List<Contract> contractList = this.appContractService.getContractListByZsProjectId(zsProjectIdStr,likeStr,start,pageSize);
        Integer pageNum = this.appContractService.getContractListByZsProjectIdSize(zsProjectIdStr,likeStr);//条数
        Map<String, DataDict> chooseHouseStatusMap = this.dataDictService.getMapByParentNameForValue("房源签认状态");
        if (CollectionUtils.isNotEmpty(contractList)){
            Map<String, Object> mapItem = null;
            Integer houseStatus = null;
            for (Contract contract : contractList) {
                mapItem = null;
                houseStatus = null;
                mapItem = Maps.newHashMap();
                mapItem.put("id", contract.getId());
                mapItem.put("zsProjectName", contract.getZsProject().getProjectName());
                mapItem.put("contractCode", contract.getContractCode());
                mapItem.put("name", contract.getName());
                mapItem.put("chooseHouseNum", contract.getChooseHouseNum());
                mapItem.put("limitHouseAreaTotal", contract.getLimitHouseAreaTotal());
                mapItem.put("chooseHouseStatusName", chooseHouseStatusMap.get(contract.getChooseHouseStatus().toString()).getName());
                mapItem.put("chooseHouseStatusColor", chooseHouseStatusMap.get(contract.getChooseHouseStatus().toString()).getColor());

                resultContractList.add(mapItem);
            }
        }
        Map resultMap = Maps.newHashMap();
        resultMap.put("resultContractList",resultContractList);
        resultMap.put("pageNum",pageNum);
        return Response.success(resultMap);
    }

    /**
     * 通过安置项目List<id>
     * 获取所需安置的房源信息
     * @param request
     * @return
     */
    @RequestMapping("getHousePic")
    public Response getHousePic(HttpServletRequest request){
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        List<House> yxHouseList = this.appYxHouseService.getYxHouseList(contractId);
        BigDecimal yxHouseArea = this.appYxHouseService.getYxHouseArea(contractId);
        List<Integer> noChooseHouseId  = ChooseLimitUtils.getCountChooseHouseIdListForApp(contract,yxHouseList,yxHouseArea);
        //通过数据字典配置得到相应展示信息
        Map phoneInfoMap = dataDictService.getMapByParentNameForName_Value("手机端公示信息配置");
        String zsProjectIdStr = phoneInfoMap.get("征收项目ID").toString();//征收项目id list
        String azProjectIdStr = phoneInfoMap.get("安置项目ID").toString();//安置项目id list

        //选择展示内容  根据楼号、可选、已选
        String buildNum = ParamUtils.getString(request, "buildNum", "");
        String kxStatusStr = ParamUtils.getString(request, "kxStatus", "");
        String yxStatusStr = ParamUtils.getString(request, "yxStatus", "");
        Integer kxStatus = kxStatusStr.equals("true") ? Status.YES.getIndex() : Status.NO.getIndex() ;
        Integer yxStatus = yxStatusStr.equals("true") ? Status.YES.getIndex() : Status.NO.getIndex() ;


        Map houseStatusMap = this.dataDictService.getMapByParentNameForValue_Color("手机端房源状态");
        Map<String, Map> houseStatusStrMap = dataDictService.getMapByParentNameForMap_Value("手机端房源状态");
        Map houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");

        //1.1 得到征收项目分配的房源id
        List houseIdList = this.appHouseService.getHouseIdList(zsProjectIdStr);
        List<String> buildNumList = this.appHouseService.getBuildNumListByAzProjectId(azProjectIdStr,houseIdList,yxStatus,kxStatus);
        if (buildNumList.size() == 0) {
            return Response.fail();
        }
        //2.当前需要展示的楼号
        if (StringUtils.isEmpty(buildNum)) {
            buildNum = buildNumList.get(0);//若是为空则默认1号楼
        }
        //3.某楼栋所有楼层
        List floorlist = this.appHouseService.floorList(azProjectIdStr,buildNum,yxStatus,kxStatus);
        //4.楼盘图房屋数据,一层一条
        int floorSize = 0;//该楼栋最多的层数
        int maxFloor = 0;//该楼栋最大的户号
        int minFloor = 1000;//该楼栋最小的户号
        List houseRoomList = Lists.newArrayList();

        for (int i = 0;i < floorlist.size(); i++) {//获取该楼栋最大户号与最小户号
            List<House> houseList = this.appHouseService.houseList(azProjectIdStr,buildNum,Integer.valueOf(floorlist.get(i).toString()),houseIdList,yxStatus,kxStatus);
            for (int num = 0;num < houseList.size();num++){
                String houseNumStr = houseList.get(num).getHouseNum();//当前房号
                Integer houseNum = Integer.valueOf(houseNumStr.substring(houseNumStr.length() - 2,houseNumStr.length()));
                maxFloor = houseNum > maxFloor ? houseNum : maxFloor;
                minFloor = houseNum < minFloor ? houseNum : minFloor;
                floorSize = maxFloor - minFloor + 1;
            }
        }
        for (int i = 0;i < floorlist.size(); i++) {
            List list = Lists.newLinkedList();//存放每层房屋信息
            Map mapParent = new HashMap();//存放每层房间数据
            //4.1 每层房屋数据
            List<House> houseList = this.appHouseService.houseList(azProjectIdStr,buildNum,Integer.valueOf(floorlist.get(i).toString()),houseIdList,yxStatus,kxStatus);
            //4.2 整层为空时  跳过
            if (houseList.size() == 0){
                continue;
            }
            //4.4 循环每层房间数据处理
            int shouldItem = minFloor;//当前应当房号
            int beforeNum = minFloor;//上一个存在的房号
            for (int num = 0;num < houseList.size();num++) {
                Map mapHouseData = Maps.newLinkedHashMap();
                House house = houseList.get(num);
                String houseNumStr = house.getHouseNum();//当前房号
                //4.4.1 获取当前房号后两位
                Integer houseNum = Integer.valueOf(houseNumStr.substring(houseNumStr.length() - 2,houseNumStr.length()));
                //4.4.2 若是非正常对应房号 则用空房号补充;否则正好存储
                /*******************第一部分  处理楼层开始非有效房源问题及楼栋中非有效房源问题 **************************/
                if (shouldItem != houseNum){

                    if (num == 0 && houseNum != minFloor) { //开始非分配房源 用null填充
                        for (int ii=beforeNum;ii < houseNum;ii++ ){
                            if (ii == 3){
                                continue;
                            }
                            Map mapHouseDataItem = Maps.newLinkedHashMap();
                            mapHouseDataItem.put("houseId",null);
                            mapHouseDataItem.put("houseHold",null);//户型
                            mapHouseDataItem.put("houseNum","");//户号
                            mapHouseDataItem.put("houseStatus",null);//房屋状态
                            mapHouseDataItem.put("buildArea",null);//房屋面积
                            mapHouseDataItem.put("houseHoldName",null);//户型
                            mapHouseDataItem.put("style", "cursor:pointer;background:#fff");
                            list.add(mapHouseDataItem);
                        }
                    } else {//中部存在非分配房源 用null填充
                        for (int ii=beforeNum;ii < houseNum-1;ii++ ){
                            //注意！！！！！！！！！  白沙选房完房可将此列判断删除；不删除不影响正常显示，无法是否存在04非分配房源
                            // 处理白沙无‘04房号’房源问题，解决非跨列显示问题
                            if (ii == 3){
                                continue;
                            }
                            Map mapHouseDataItem = Maps.newLinkedHashMap();
                            mapHouseDataItem.put("houseId",null);
                            mapHouseDataItem.put("houseHold",null);//户型
                            mapHouseDataItem.put("houseNum","");//户号
                            mapHouseDataItem.put("houseStatus",null);//房屋状态
                            mapHouseDataItem.put("buildArea",null);//房屋面积
                            mapHouseDataItem.put("houseHoldName",null);//户型
                            mapHouseDataItem.put("style", "cursor:pointer;background:#fff");
                            list.add(mapHouseDataItem);
                        }
                    }
                }
                /*******************第二部分  有效房源正常封装 若不按顺序排列去除第一部分与第三部分 **************************/
                mapHouseData.put("houseId",house.getId());
                mapHouseData.put("houseHold",house.getHouseHold());//户型
                mapHouseData.put("houseNum",house.getHouseNum());//户号
                Integer houseStatus = house.getHouseStatus();
                //不可选状态设置
                if (contract.getChooseLimitType() != 1) {//有限制 状态做处理
                    if (noChooseHouseId == null && house.getHouseStatus() == 1) {//若是空都不可选
                        houseStatus = 3;
                    } else if (noChooseHouseId != null && noChooseHouseId.contains(house.getId()) && house.getHouseStatus() == 1) {//已选房屋颜色优先级 高于 不可选优先级
                        houseStatus = 3;
                    }
                }

                mapHouseData.put("houseStatus",houseStatus);//房屋状态
                mapHouseData.put("buildArea",house.getBuildArea());//房屋面积
                mapHouseData.put("houseHoldName",houseHoldMap.get(house.getHouseHold()));//户型
                //4.4.3 根据房间状态上色
                //houseStatus 下面语句勿修改，泉州选房只展示两种状态

                mapHouseData.put("style", "cursor:pointer;background:" + houseStatusMap.get(String.valueOf(houseStatus)));
                list.add(mapHouseData);
                //4.4.4 将正常房号赋值给beforeNum
                beforeNum = houseNum;
                //4.4.5 当前应当房号 + 1
                shouldItem = houseNum + 1;
                /*******************第三部分  处理尾部房源非有效部分 **************************/
                String lastHouseNumStr = houseList.get(houseList.size() -1).getHouseNum();
                Integer lastHouseNum = Integer.valueOf(lastHouseNumStr.substring(lastHouseNumStr.length() - 2,lastHouseNumStr.length()));
                if (num == houseList.size()-1 && maxFloor > lastHouseNum) { //判断该层最大号是否是该层最大号，若不是需将后续楼号也用空补充
                    for (int j=lastHouseNum;j < maxFloor;j++ ){ //若是非分配房源，用空值填充
                        //注意！！！！！！！！！  白沙选房完房可将此列判断删除；不删除不影响正常显示，无法是否存在04非分配房源
                        // 处理白沙无‘04房号’房源问题，解决非跨列显示问题
                        if (j == 3){
                            continue;
                        }
                        Map mapHouseDataItem = Maps.newLinkedHashMap();
                        mapHouseDataItem.put("houseId",null);
                        mapHouseDataItem.put("houseHold",null);//户型
                        mapHouseDataItem.put("houseNum","");//户号
                        mapHouseDataItem.put("houseStatus",null);//房屋状态
                        mapHouseDataItem.put("buildArea",null);//房屋面积
                        mapHouseDataItem.put("houseHoldName",null);//户型
                        mapHouseDataItem.put("style", "cursor:pointer;background:#fff");
                        list.add(mapHouseDataItem);
                    }
                }
            }
            mapParent.put("name",floorlist.get(i));
            mapParent.put("value",list);
            houseRoomList.add(mapParent);
        }

        Map<String,String> houseTypeMap = dataDictService.getMapByParentNameForValue_Name("房屋户型");
        Map<String,String> carTypeMap = dataDictService.getMapByParentNameForValue_Name("车位类型");
        //此选房号之前该房已被预选次数
        Precondition.checkAjaxArguement(BigUtils.isDigit(contract.getChooseHouseNum()),"1111","选房号不是纯数字，请联系管理员核对！！");
        Map<String,Integer> yxHouseNumMap = this.appHouseService.getYxHouseNum(contract.getChooseHouseNum());

        Map resultMap = Maps.newHashMap();
        resultMap.put("yxHouseNumMap",yxHouseNumMap);
        resultMap.put("buildNumList",buildNumList);
        resultMap.put("floorlist",floorlist);
        resultMap.put("houseRoomList",houseRoomList);
        resultMap.put("houseStatusMap",houseStatusMap);
        resultMap.put("houseStatusStrMap",houseStatusStrMap);
        resultMap.put("floorSize",floorSize);
        resultMap.put("contract",contract);

        resultMap.put("houseTypeMap",houseTypeMap);
        resultMap.put("carTypeMap",carTypeMap);
        return Response.success(resultMap);
    }

    /**
     * 添加预选house
     * @param request
     * @return
     */
    @RequestMapping("tjYxHouse")
    public Response yxHouseList(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        List<Integer> yxHouseIdList = this.appYxHouseService.getHouseIdByContractId(contract.getId());
        if (!yxHouseIdList.contains(houseId) && houseId != 0 && contract.getId() != 0){//该户不在预选中
            YxHouse yxHouse = new YxHouse();
            yxHouse.setHouseId(houseId);
            yxHouse.setContractId(contract.getId());
            this.appYxHouseService.save(yxHouse);
            //从备选列表中删除
            this.appBxHouseService.deleteBxHouse(houseId,contractId);
        }
        return Response.success(resultMap);
    }

    /**
     * 添加意向house
     * @param request
     * @return
     */
    @RequestMapping("tjBxHouseList")
    public Response tjBxHouseList(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        List<Integer> bxHouseIdList = this.appBxHouseService.getHouseIdByContractId(contract.getId());
        if (!bxHouseIdList.contains(houseId) && houseId != 0 && contract.getId() != 0){//该户不在预选中
            BxHouse bxHouse = new BxHouse();
            bxHouse.setHouseId(houseId);
            bxHouse.setContractId(contract.getId());
            this.appBxHouseService.save(bxHouse);
        }
        return Response.success(resultMap);
    }

    /**
     * 备选房源信息删除
     * @param request
     * @return
     */
    @RequestMapping("deleteBxHouseList")
    public Response deleteBxHouseList(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        this.appBxHouseService.deleteBxHouse(houseId,contractId);//删除备选房源
        return Response.success(resultMap);
    }

    /**
     * 方案预选信息
     * @param request
     * @return
     */
    @RequestMapping("showYxInfo")
    public Response showYxInfo(HttpServletRequest request) {
        Map resultMap = Maps.newHashMap();
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        /*预选信息*/
        List<Integer> yxHouseIdList = this.appYxHouseService.getHouseIdByContractId(contract.getId());
        List<House> houseList = this.appHouseService.houseListByIdList(yxHouseIdList);
        BigDecimal yxHouseArea = this.appYxHouseService.getYxHouseArea(contract.getId());
        BigDecimal syAzArea = BigDecimalUtils.getBigAndBigSub(contract.getLimitHouseAreaTotal(),yxHouseArea);
        resultMap.put("houseList",houseList);
        resultMap.put("syAzArea",syAzArea);
        /*备选信息*/
        Map<String,String> holdMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        List<Integer> bxHouseIdListItem = this.appBxHouseService.getHouseIdByContractId(contract.getId());
        //得到户型list
        List<String> houseHoldList = this.appHouseService.getHouseHoldByIdList(bxHouseIdListItem);
        List<House> bxHouseList = this.appHouseService.houseListByIdList(bxHouseIdListItem);
        //根据户型封装状态
        Map houseStatusMap = this.dataDictService.getMapByParentNameForValue_Color("手机端房源状态");
        List<House> yxHouseList = this.appYxHouseService.getYxHouseList(contractId);
        List<Integer> noChooseHouseId  = ChooseLimitUtils.getCountChooseHouseIdListForApp(contract,yxHouseList,yxHouseArea);
        Map<String, List<Map<String,Object>>> bxHouseByHoldMap = this.appHouseService.getBxHouseByHold(bxHouseIdListItem,houseStatusMap,contract,noChooseHouseId);
        //已选车位list
        List<CarLot> yxCarList = this.appYxCarLotService.getYxCarLotList(contractId);

        resultMap.put("bxHouseByHoldMap",bxHouseByHoldMap);
        resultMap.put("holdMap",holdMap);
        resultMap.put("houseHoldList",houseHoldList);
        resultMap.put("bxHouseList",bxHouseList);
        resultMap.put("yxCarList",yxCarList);
        return Response.success(resultMap);
    }

    /**
     * 添加预选carLot
     * @param request
     * @return
     */
    @RequestMapping("tjYxCarLot")
    public Response tjYxCarLot(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer carLotId = ParamUtils.getInt(request, "carLotId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        List<Integer> yxCarLotIdList = this.appYxCarLotService.getCatLotIdByContractId(contractId);
        if (!yxCarLotIdList.contains(carLotId) && carLotId != 0 && contractId != 0){//该户不在预选中
            YxCarLot yxCarLot = new YxCarLot();
            yxCarLot.setCarLotId(carLotId);
            yxCarLot.setContractId(contractId);
            this.appYxCarLotService.save(yxCarLot);
        }
        List<CarLot> yxCarList = this.appYxCarLotService.getYxCarLotList(contractId);
        resultMap.put("yxCarList",yxCarList);
        return Response.success(resultMap);
    }

    /**
     * 预选房源信息删除
     * @param request
     * @return
     */
    @RequestMapping("deleteYxHouse")
    public Response deleteYxHouse(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        //先将预选房源存入备选中
        List<Integer> bxHouseIdList = this.appBxHouseService.getHouseIdByContractId(contractId);
        if (!bxHouseIdList.contains(houseId) && houseId != 0 && contractId != 0){//该户不在预选中
            BxHouse bxHouse = new BxHouse();
            bxHouse.setHouseId(houseId);
            bxHouse.setContractId(contractId);
            this.appBxHouseService.save(bxHouse);
        }
        //删除预选房源
        this.appYxHouseService.deleteYxHouse(houseId,contractId);
        List<Integer> yxHouseIdListItem = this.appYxHouseService.getHouseIdByContractId(contractId);
        List<House> houseList = this.appHouseService.houseListByIdList(yxHouseIdListItem);
        resultMap.put("houseList",houseList);
        return Response.success(resultMap);
    }

    /**
     * 预选车位信息删除
     * @param request
     * @return
     */
    @RequestMapping("deleteYxCarLot")
    public Response deleteYxCarLot(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer carLotId = ParamUtils.getInt(request, "carLotId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        this.appYxCarLotService.deleteYxCatLot(carLotId,contractId);//删除预先房源
        List<CarLot> yxCarList = this.appYxCarLotService.getYxCarLotList(contractId);
        resultMap.put("yxCarList",yxCarList);
        return Response.success(resultMap);
    }

    /**
     *
     * 通过房屋Id得到房屋实体
     * @param request
     * @return
     */
    @RequestMapping("houseInfo")
    public Response houseInfo(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        String houseId = ParamUtils.getString(request, "houseId", "");
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        if (houseId.equals("undefined")){ //解决未分配房源点击查看情况
            resultMap.put("buildNum","");
            resultMap.put("floor","");
            resultMap.put("houseNum","非本次房源");
            resultMap.put("houseHold","");
            resultMap.put("buildArea","");
            resultMap.put("houseStatus","");
            resultMap.put("houseColor","#ede1d9");
            resultMap.put("chooseHouseNum","");
            resultMap.put("zsProjectName","");
        } else {
            House house = this.appHouseService.findOne(Integer.valueOf(houseId));
            Map houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
            Map<String, Map> houseStatusStrMap = dataDictService.getMapByParentNameForMap_Value("手机端房源状态");
            //几幢楼  几层 房号 几室几厅  建筑面积  手机端房源状态
            resultMap.put("id",house.getId());
            resultMap.put("buildNum",house.getBuildNum() + "幢");
            resultMap.put("floor",house.getFloor() + "层");
            resultMap.put("houseNum",house.getHouseNum());
            resultMap.put("houseHold",houseHoldMap.get(house.getHouseHold()));
            resultMap.put("buildArea",house.getBuildArea());
            resultMap.put("propertyArea",house.getPropertyArea());
            resultMap.put("poolArea",house.getPoolArea());
            resultMap.put("houseStatus",houseStatusStrMap.get(house.getHouseStatus().toString()).get("name"));
            resultMap.put("houseColor",houseStatusStrMap.get(house.getHouseStatus().toString()).get("color"));
            resultMap.put("chooseHouseNum",house.getContract() == null ? "" : house.getContract().getChooseHouseNum());
            resultMap.put("zsProjectName",house.getContract() == null ? "" : house.getContract().getZsProject().getProjectName());
        }
        return Response.success(resultMap);
    }

    /**
     * 不可选房源提示
     * @param request
     * @return
     */
    @RequestMapping("selectHouseWarn")
    public Response selectHouseWarn(HttpServletRequest request){
        Map resultMap = Maps.newHashMap();
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        House house = this.appHouseService.findOne(houseId);
        Contract contract = this.contractService.findOne(contractId);
        String warnString = ChooseLimitUtils.getChooseLimit(contract,house);
        resultMap.put("warnString",warnString);
        return Response.success(resultMap);
    }
}
